# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=pipe-rename
pkgver=1.6.5
pkgrel=1
pkgdesc='Rename your files using your favorite text editor'
arch=('loong64' 'x86_64')
url='https://github.com/marcusbuffett/pipe-rename'
license=('MIT')
depends=('glibc' 'gcc-libs')
makedepends=('git' 'rust')
options=('!lto')
_commit='a3c0bafaccdd8d08953745183d3887dc4792e476'
source=(
  "$pkgname::git+$url#commit=$_commit"
  'LICENSE'
)
sha512sums=('SKIP'
            '3a3dbfd7a5a8d02a3a96bb1652bd25cae21d1080b941ecd3bee3f46e98b4a2f30b4a7ecdeb1e55ec2bf8bfefbeb9500287acb964ccb7149a405ee28eebd05889')
b2sums=('SKIP'
        'abec091be86ec71b15a70251d769d4177639881c28d71fb9127d86cf711514e0fe40e80edd645e97df532980baf13380433fd2b497e03b4021d49e87434a4965')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname"

  cargo build --frozen --release
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" target/release/renamer

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" "$srcdir/LICENSE"
}
